#include <iostream>
#include <string>
#include "svm_trainer.h"

int main(int argc, char** argv) {
    std::string dataset_path = "dataset";
    std::string model_save_path = "models/svm_model.xml";
    
    // 可以通过命令行参数指定路径
    if (argc >= 2) {
        dataset_path = argv[1];
    }
    if (argc >= 3) {
        model_save_path = argv[2];
    }
    
    std::cout << "=== SVM Number Classifier Training ===" << std::endl;
    std::cout << "Dataset path: " << dataset_path << std::endl;
    std::cout << "Model save path: " << model_save_path << std::endl;
    
    SVMTrainer trainer;
    
    // 加载数据集
    if (!trainer.loadDataset(dataset_path)) {
        std::cout << "Failed to load dataset!" << std::endl;
        return -1;
    }
    
    // 分割训练集和测试集
    trainer.setTrainTestSplit(0.8); // 80% 训练，20% 测试
    
    // 训练模型
    if (!trainer.trainModel(model_save_path)) {
        std::cout << "Failed to train model!" << std::endl;
        return -1;
    }
    
    std::cout << "Training completed successfully!" << std::endl;
    return 0;
}